<%--
    Document   : buscar
    Created on : 26/05/2009, 08:52:31 PM

--%>

<%@page contentType="text/html" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<link href="/general/css/admin_1.css" rel="stylesheet" type="text/css"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<f:view>
    <t:div>
        <h:form>
            <h:inputHidden value="#{tramiteController.inicio}"/>
            <rich:modalPanel height="80" width="400" id="Modal1" resizeable="false" moveable="false" showWhenRendered="true" rendered="#{tramiteController.modalAceptar}">
                <f:facet name="header">
                    <h:panelGroup>
                        <h:outputText value="Cargar Tramites" />
                    </h:panelGroup>
                </f:facet>
                <h:panelGroup>
                    <h:form>
                        <br>
                        <h:outputLabel value="No existen Tramites Registrados desea Cargar los Tramites predeterminados?" />
                        <br>
                    </h:form>                    
                    <a4j:commandButton action="#{tramiteController.aceptarModal}" value="Aceptar" reRender="panelD" />
                    <a4j:commandButton action="#{tramiteController.cancelarModal}" value="Cancelar" />
                    <rich:componentControl for="Modal1" operation="hide" event="onclick"/>                    
                </h:panelGroup>
            </rich:modalPanel>

            <a4j:outputPanel id="panelD" ajaxRendered="true">
            <rich:modalPanel height="350" width="500" id="Modal2" resizeable="false" moveable="false" showWhenRendered="true" rendered="#{tramiteController.modalCargar}">
                <f:facet name="header">
                    <h:panelGroup>
                        <h:outputText value="Cargar Tramites" />
                    </h:panelGroup>
                </f:facet>
                <h:panelGroup>
                    <h:form>
                        <rich:scrollableDataTable id="scTabla" value="#{tramiteController.tramitesCargar}"var="tram" width="320px" height="270px">
                            <rich:column width="40">
                                <f:facet name="header"> <h:outputLabel value="" /></f:facet>
                                <h:selectBooleanCheckbox value="#{tram.seleccionado}"/>
                            </rich:column>
                            <rich:column width="260">
                                <f:facet name="header"> <h:outputLabel value="NOMBRE" /></f:facet>
                                <h:outputText value="#{tram.trmNombre}" />
                            </rich:column>
                        </rich:scrollableDataTable>
                    </h:form>
                    <a4j:commandButton id="btnAceptar" action="#{tramiteController.aceptarModalC}" value="Si" />
                    <a4j:commandButton id="btnCancelar" action="#{tramiteController.aceptarModalC}" value="No" />
                    <rich:componentControl attachTo="btnAceptar, btnCancelar" for="Modal2" operation="hide" event="onclick"/>
                </h:panelGroup>
            </rich:modalPanel>
            </a4j:outputPanel>
            <h:panelGrid columns="1" styleClass="rayaForms" width="100%">
                <h:outputLabel  value="TRAMITES" />
            </h:panelGrid>
            <h:panelGrid columns="2" >
                <h:outputLabel value="Nombre" />
                <h:inputText value="#{tramiteController.tramite.trmNombre}" />

                <h:commandButton action="#{tramiteController.buscar}" value="Buscar" />
                <h:commandButton action="#{tramiteController.nuevo}" value="Nuevo" />
            </h:panelGrid>
            <br><br>

            <rich:dataTable value="#{tramiteController.tramites}"
                            var="tramite" rows="15" reRender="ds" id="simpletable"
                            width="100%" columnsWidth="5%, 40%, 40%, 15%">
                <rich:column>
                    <f:facet name="header"> <h:outputLabel value="CODIGO" /></f:facet>
                    <h:outputText value="#{tramite.trmCodigo}" />
                </rich:column>
                <rich:column>
                    <f:facet name="header"> <h:outputLabel value="NOMBRE" /></f:facet>
                    <h:outputText value="#{tramite.trmNombre}" />
                </rich:column>
                <rich:column>
                    <f:facet name="header"> <h:outputLabel value="DESCRIPCION" /></f:facet>
                    <h:outputText value="#{tramite.trmDescripcion}" />
                </rich:column>
                <rich:column>
                    <f:facet name="header"> <h:outputLabel value="OPCIONES" /></f:facet>
                    <h:commandLink action="#{tramiteController.editar}" value="Editar" >
                        <f:setPropertyActionListener target="#{tramiteController.tramite}" value="#{tramite}" />
                    </h:commandLink>
                </rich:column>
                <f:facet name="footer">
                    <rich:datascroller id="ds" renderIfSinglePage="false"></rich:datascroller>
                </f:facet>
            </rich:dataTable>
        </h:form>
    </t:div>
</f:view>
